﻿using Force.DeepCloner;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Windows.Forms;

namespace DmWordReplaceEx
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
            forms = new List<Form>()
            {
              new WordReplace() ,
              new WordTemplateBuild(),
              new About()
            };
            forms.ForEach(p =>
            {
                p.FormBorderStyle = FormBorderStyle.None;
                p.TopLevel = false;
            });
          
        }
       private readonly List<Form> forms;

        public void ShowForm<T>() where T : Form, new()
        {
            var fm = forms.OfType<T>().ToList().FirstOrDefault();
            if (fm == null)
            {
                return;
            }

            pl_controlShow.Controls.Clear();
            pl_controlShow.Controls.Add(fm);
            fm.Show();
        }
        private void tool_wordFindReplac_Click(object sender, EventArgs e)
        {
            ShowForm<WordReplace>();
        }

       

        private void tool_wordTemplateBuild_Click(object sender, EventArgs e)
        {
            ShowForm<WordTemplateBuild>();
        }


        private void aboutToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            ShowForm<About>();
        }

        private void mostTopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.TopMost = true;
            ((ToolStripMenuItem)sender).BackColor = SystemColors.ActiveCaption;
            mostTopCancelToolStripMenuItem.BackColor= SystemColors.Control;
        }

        private void mostTopCancelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.TopMost = false;
            ((ToolStripMenuItem)sender).BackColor = SystemColors.ActiveCaption;
            mostTopToolStripMenuItem.BackColor = SystemColors.Control;
        }
    }
}
